#define  _CRT_SECURE_NO_WARNINGS 1

#include "test.h"

void game()
{
	//存储数据 -- 二维数组
	char board[ROW][COL];
	//初始化棋盘 -- 填满空格
	Initboard(board, ROW, COL);
	//打印棋盘
	Putboard(board, ROW, COL);
	//接收游戏状态
	char ret = 0;
	while (1)
	{
		//玩家下棋
		Playermove(board, ROW, COL);
		Putboard(board, ROW, COL);
		//判断游戏状态
		ret = Is_win(board, ROW, COL);
		if (ret != 'A')
		{
			break;
		}
		//电脑下棋
		PCmove(board, ROW, COL);
		Putboard(board, ROW, COL);
		//判断游戏状态
		ret = Is_win(board, ROW, COL);
		if (ret != 'A')
		{
			break;
		}
	}
	if (ret == '*')
	{
		printf("你赢了\n");
		Initboard(board, ROW, COL);
	}
	else if (ret == '#')
	{
		printf("你输了\n");
		Initboard(board, ROW, COL);
	}
	else
	{
		printf("平局\n");
		Initboard(board, ROW, COL);
	}
}

int main()
{
	int n = 0;
	srand((unsigned int)time(NULL));
	do
	{
		menu();
		printf("请选择->");
		scanf("%d", &n);
		switch(n)
		{
		case 1:
			game();
			break;
		case 0:
			printf("游戏结束");
			break;
		default:
			printf("输入错误，请重新输入");
			break;
		}
	} while (n);
	return 0;
}